//
// Created by francklinson on 2021/12/4 AT 9:43.
// May Saint Diana bless you!
//

#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <functional>
#include <climits>
#include <string>

using namespace std;

class Solution {
public:
    int numWaterBottles(int numBottles, int numExchange) {
        int ans = numBottles;
        while (numBottles >= numExchange) {
            int newBottles = numBottles / numExchange;
            ans += newBottles;
            numBottles = numBottles % numExchange + newBottles;
        }
        return ans;
    }
};

int main() {
    Solution solution;
    cout << solution.numWaterBottles(9, 3) << endl;
    return 0;
}

